package com.portal.web.action.system.role;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.portal.model.system.Role;
import com.portal.web.action.BaseAction;
import com.util.portal.PageConfig;

/**
 * 角色管理主页面
 * @author liu.qiao
 *
 */
public class Main extends BaseAction {
	private static final long serialVersionUID = 1L;
	private String rows;//每页显示的记录数  
	private String page;//当前第几页  
	private List<Role> rolelist;
	private Map<String, Object> roleListMap;

    public String execute() throws Exception {
    	try {
    		Role role = new Role();
    		
    		PageConfig pageConfig = new PageConfig();
    		if(this.getPage()!=null){
    			pageConfig.setPageIndex(Integer.parseInt(this.getPage()));
    		}
    		if(this.getRows()!=null){
    			pageConfig.setPageSize(Integer.parseInt(this.getRows()));
    		}
    		
    		rolelist = this.getServiceContainer().getRoleService().getList(role, pageConfig);
    		Map<String, Object> jsonMap = new HashMap<String, Object>();
			jsonMap.put("rows", rolelist);
			jsonMap.put("total", pageConfig.getTotalCount());
			roleListMap = jsonMap;
		} catch (Exception e) {
			e.printStackTrace();
			return ERROR;
		}
        return SUCCESS;
    }


	public List<Role> getRolelist() {
		return rolelist;
	}

	public void setRolelist(List<Role> rolelist) {
		this.rolelist = rolelist;
	}

	public Map<String, Object> getRoleListMap() {
		return roleListMap;
	}

	public void setRoleListMap(Map<String, Object> roleListMap) {
		this.roleListMap = roleListMap;
	}

	public String getRows() {
		return rows;
	}

	public void setRows(String rows) {
		this.rows = rows;
	}

	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}
}
